package com.zlp.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

@Controller
public class LoginController {

    /**
     * 页面跳转
     * @return
     */
    @GetMapping("/showLogin")
    public String showLogin(){
        return "login.html";
    }


    /**
     * 成功后跳转页面
     */
    @PostMapping("/toMain")
    @PreAuthorize("hasRole('ROLE_abc')")
    public String toMain() {
        return "redirect:/main.html";
    }

    /**
     * 失败后跳转页面
     * @return
     */
    @PostMapping("/toError")
    public String toError() {
        return "redirect:/error.html";
    }
}
